package com.e_manager.soft.emanager.controller;

import com.e_manager.soft.emanager.annotation.Authorization;
import com.e_manager.soft.emanager.annotation.BaseController;
import com.e_manager.soft.emanager.entity.Statistics;
import com.e_manager.soft.emanager.entity.StatisticsHour;
import com.e_manager.soft.emanager.entity.parameter.StatisticHourParameter;
import com.e_manager.soft.emanager.resultMsg.ResultConstant;
import com.e_manager.soft.emanager.resultMsg.ResultInfo;
import com.e_manager.soft.emanager.service.MstMessageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * [StatisticsController]<br>
 * 统计信息<br>
 * <br>
 * [功能概要]<br>
 * 统计信息<br>
 * <br>
 * [更新履历]<br>
 * 2018/03/22 ver1.00 JYS CORPORATION<br>
 *
 * @author JYS CORPORATION
 * @version 1.00
 */
@BaseController
@Authorization
public class StatisticsController {
    @Autowired
    private MstMessageService mstMessageService;

    @ApiOperation(value = "web按月统计", notes = "web按月统计")
    @PostMapping(value = "/statistics", produces = {"application/json;charset=utf-8"})
    public ResultInfo<?> statisticsList() {
        ResultInfo resultInfo = new ResultInfo();
        try {
            //列表
            Statistics list = mstMessageService.queryStatistics();
            //返回信息
            resultInfo.setMsg(ResultConstant.SUCCESS.getMessage());
            resultInfo.setData(list);
            resultInfo.setCode(ResultConstant.SUCCESS.getCode());
        } catch (Exception e) {
            resultInfo.setMsg(ResultConstant.FAIL.getMessage());
            resultInfo.setCode(ResultConstant.FAIL.getCode());
            e.printStackTrace();
        }
        return resultInfo;
    }

    @ApiOperation(value = "安卓按天统计", notes = "安卓按天统计")
    @PostMapping(value = "/statisticsHourList", produces = {"application/json;charset=utf-8"})
    public ResultInfo<?> statisticsHourList(@RequestBody StatisticHourParameter statisticHourParameter) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            //列表
            StatisticsHour list = mstMessageService.queryHourStatistics(statisticHourParameter);
            //返回信息
            resultInfo.setMsg(ResultConstant.SUCCESS.getMessage());
            resultInfo.setData(list);
            resultInfo.setCode(ResultConstant.SUCCESS.getCode());
        } catch (Exception e) {
            resultInfo.setMsg(ResultConstant.FAIL.getMessage());
            resultInfo.setCode(ResultConstant.FAIL.getCode());
            e.printStackTrace();
        }
        return resultInfo;
    }
}
